﻿using IBll;
using IDal;
using Model.DTO;
using Model.Order;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Bll
{
    public class HouseOrderBll : IHouseOrderBll
    {
        private readonly IHouseOrderDal dal;

        public HouseOrderBll(IHouseOrderDal dal)
        {
            this.dal = dal;
        }
        /// <summary>
        /// 创建订单
        /// </summary>
        /// <param name="houseOrder">订单表</param>
        /// <returns>返回受影响行数</returns>
        public int AddOrder(HouseOrder houseOrder)
        {
            return dal.AddOrder(houseOrder);
        }
        /// <summary>
        /// 订单的显示+查询+分页
        /// </summary>
        /// <param name="loginname">登录人</param>
        /// <param name="max">时间最大值</param>
        /// <param name="min">时间最小值</param>
        /// <param name="name">入住人进行模糊查询</param>
        /// <param name="pageindex">当前页</param>
        /// <param name="pagesize">每页显示的条数</param>
        /// <returns></returns>
        public dynamic ShowOrder(string loginname = "", DateTime? max = null, DateTime? min = null, string? name = "", int pageindex = 1, int pagesize = 3)
        {
            return dal.ShowOrder(loginname, max, min, name, pageindex, pagesize);
        }
        /// <summary>
        /// 逻辑删除
        /// </summary>
        /// <param name="id">主键id</param>
        /// <returns>返回受影响行数</returns>
        public int UpdateCodeState(int id)
        {
            return dal.UpdateCodeState(id);
        }
        /// <summary>
        /// 获取验证码
        /// </summary>
        /// <param name="orderid">订单id</param>
        /// <param name="phone">通过手机号获取验证码</param>
        /// <returns>验证码</returns>
        public int Code(int orderid, string phone)
        {
            return dal.Code(orderid, phone);
        }
        /// <summary>
        /// 办理入住
        /// </summary>
        /// <param name="code">手动输入的验证码</param>
        /// <param name="codes">自动生成的验证啊</param>
        /// <param name="phone">手机号</param>
        /// <returns>返回受影响行数</returns>
        public int CheckIn(int code, int codes, string phone = "")
        {
            return dal.CheckIn(code, codes, phone);
        }
    }
}
